
USE [{0}]

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_CUSTOMER')
	BEGIN
		CREATE TABLE [dbo].[ODB_CUSTOMER](
			[CUSTOMER_ID] [nvarchar](20) ,
			[CUSTOMERNAME] [nvarchar](60) ,
			[STREET] [nvarchar](250) ,
			[ZIPCODE] [nvarchar](10) ,
			[CITY] [nvarchar](60) ,
			[COUNTRY] [nvarchar](10) ,
			[TELEPHONE] [nvarchar](20) ,
			[TELEFAX] [nvarchar](20) ,
			[TELEX] [nvarchar](20) ,
			[CONTACTPERSON] [nvarchar](20) ,
			[REPRESENTATIVE] [nvarchar](20) ,
			[CUSTOMERCOMMENT] [nvarchar](80) ,
			[BILLTO] [nvarchar](40) ,
			[SHIPTO] [nvarchar](40) ,
			[EMAIL] [nvarchar](40) ,
			[WEBSITE] [nvarchar](40) )

	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_CUSTORDER')
	BEGIN
		CREATE TABLE [dbo].[ODB_CUSTORDER](
			[CUSTOMER_ID] [nvarchar](20) ,
			[AUTHOR] [nvarchar](20) ,
			[ORDERDATE] [datetime] ,
			[CUSTORDER_ID] [int] )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_PREPORDER')
	BEGIN
		CREATE TABLE [dbo].[ODB_PREPORDER](
			[PREPORDER] [int] ,
			[NOMINALENDTS] [datetime] ,
			[NOMINALENDTSTZID] [int] ,
			[PREPORDERCOMMENT] [nvarchar](60) ,
			[WARPTYPE_ID] [nvarchar](10) ,
			[NUMBEROFSECBEAMS] [int] ,
			[NUMBEROFWARPS] [int] ,
			[NOMINALLENGTH] [numeric](28, 12) ,
			[GENERATE] [int] )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_PREPORDERPASS')
BEGIN
	CREATE TABLE [dbo].[ODB_PREPORDERPASS](
		[PREPORDER] [int] ,
		[STEP_ID] [int] ,
		[NOMINALBEGTS] [datetime] ,
		[NOMINALBEGTSTZID] [int] ,
		[NOMINALENDTS] [datetime] ,
		[NOMINALENDTSTZID] [int] ,
		[NOMINALSPEED] [numeric](28, 12) ,
		[NOMINALEFF] [numeric](28, 12) ,
		[NOMINALLOADDURATION] [int] ,
		[NOMINALUNLOADDURATION] [int] ,
		[BEGTS] [datetime] ,
		[BEGTSTZID] [int] ,
		[ENDTS] [datetime] ,
		[ENDTSTZID] [int] ,
		[LENGTH] [numeric](28, 12) ,
		[MONITORDURATION] [int] ,
		[STOPDURATION] [int] ,
		[DOWNDURATION] [int] ,
		[LOADDURATION] [int] ,
		[UNLOADDURATION] [int] ,
		[WARPINPUTLIST] [int] ,
		[WARPOUTPUTLIST] [int] ,
		[PROCESS_ID] [nvarchar](10) ,
		[MACHTYPE_ID] [nvarchar](4) ,
		[MACH_ID] [int] ,
		[STOPLIMITSET_ID] [int] ,
		[COMMENTS] [nvarchar](80) )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_PREPORDERWARPLIST')
	BEGIN
		CREATE TABLE [dbo].[ODB_PREPORDERWARPLIST](
			[PREPORDER] [int] ,
			[WARPLIST_ID] [int] ,
			[POSITION] [int] ,
			[SEQUENCE] [int] ,
			[WARP_ID] [int] )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_PRODORDER')
	BEGIN
		CREATE TABLE [dbo].[ODB_PRODORDER](
			[PRODORDER_ID] [int] ,
			[PLANNEDSTARTDATE] [datetime] ,
			[PLANNEDSTARTDATETZID] [int] ,
			[PLANNEDSETUPDURATION] [int] ,
			[PLANNEDMACHTYPE_ID] [nvarchar](4) ,
			[MACH_ID] [int] ,
			[WARP_ID] [int] ,
			[WARPTYPE_ID] [nvarchar](20) ,
			[NOMINALLENGTH] [numeric](28, 12) ,
			[PLANNEDLENGTH] [numeric](28, 12) ,
			[NOMINALPIECELENGTH] [numeric](28, 12) ,
			[NOMINALSPEED] [numeric](28, 12) ,
			[PRIORITY] [int] ,
			[STYLE_ID1] [nvarchar](20) ,
			[WIDTH_ID2] [numeric](28, 12) ,
			[NOOFPIECEPRODLINE1] [int] ,
			[STYLE_ID2] [nvarchar](10) ,
			[WIDTH_ID1] [numeric](28, 12) ,
			[NOOFPIECEPRODLINE3] [int] ,
			[WIDTH_ID4] [numeric](28, 12) ,
			[STYLE_ID3] [nvarchar](20) ,
			[NOOFPIECEPRODLINE2] [int] ,
			[WIDTH_ID3] [numeric](28, 12) ,
			[STYLE_ID4] [nvarchar](20) ,
			[NOOFPIECEPRODLINE4] [int] ,
			[CUSTORDER_ID4] [int] ,
			[SUBCUSTORDER_ID4] [int] ,
			[CUSTORDER_ID1] [int] ,
			[CUSTORDER_ID2] [int] ,
			[SUBCUSTORDER_ID1] [int] ,
			[SUBCUSTORDER_ID2] [int] ,
			[CUSTORDER_ID3] [int] ,
			[SUBCUSTORDER_ID3] [int] ,
			[SUBPORDCOMMENT] [nvarchar](80) ,
			[UPDPRODPROG] [int] ,
			[CREATEPIECES] [int] )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_STYLE')
	BEGIN
		CREATE TABLE [dbo].[ODB_STYLE](
			[STYLE_ID] [nvarchar](20) ,
			[DENSITY] [numeric](28, 12) ,
			[CONTRACTION] [numeric](28, 12) ,
			[PICKFACTOR] [int] ,
			[NOMINALPIECELENGTH] [numeric](28, 12) ,
			[STYLECOMMENT] [nvarchar](80) ,
			[STOPLIMITSET_ID] [int] ,
			[ACTIVE] [int] ,
			[COLOR] [int] ,
			[NOOFPIECEPRODLINE] [numeric](28, 12) ,
			[PATTERN] [nvarchar](16) ,
			[STYLECOLOR] [nvarchar](16) ,
			[NOMINALPIECEWEIGHTM2] [numeric](28, 12) ,
			[STYLEGRP_ID] [nvarchar](20) )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_STYLEWARP')
	BEGIN
		CREATE TABLE [dbo].[ODB_STYLEWARP](
			[STYLE_ID] [nvarchar](10) ,
			[WIDTH_ID] [numeric](28, 12) ,
			[LINE] [int] ,
			[ETAGE] [int] ,
			[CONTRACTION] [numeric](28, 12) ,
			[WARPTYPE_ID] [nvarchar](20) )
			END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_STYLEWIDTH')
	BEGIN
		CREATE TABLE [dbo].[ODB_STYLEWIDTH](
			[STYLE_ID] [nvarchar](10) ,
			[WIDTH_ID] [numeric](28, 12) ,
			[NOMINALSPEED] [numeric](28, 12) ,
			[NOMINALPRODEFF] [numeric](28, 12) ,
			[STOPLIMITSET_ID] [int] ,
			[MACHTYPE_ID] [nvarchar](4) ,
			[NOOFPIECEPRODLINE] [int] ,
			[DENSITY] [numeric](28, 12) ,
			[COST] [numeric](28, 12) ,
			[WORKLOAD] [numeric](28, 12) )
		END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_SUBCUSTORDER')
	BEGIN
	CREATE TABLE [dbo].[ODB_SUBCUSTORDER](
		[STYLE_ID] [nvarchar](16) ,
		[WIDTH_ID] [numeric](28, 12) ,
		[CUSTORDER_ID] [int] ,
		[SUBCUSTORDER_ID] [int] ,
		[DELIVERYAMOUNT] [numeric](28, 12) ,
		[PIECELENGTH] [numeric](28, 12) ,
		[FINISH] [nvarchar](12) ,
		[PLANNEDDELIVERYDATE] [datetime] ,
		[PLANNEDDELIVERYDATETZID] [int] ,
		[SUBCORDCOMMENT] [nvarchar](80) ,
		[CUSTSTYLE_ID] [nvarchar](10) ,
		[STYLEEXT1_ID] [nvarchar](10) ,
		[STYLEEXT2_ID] [nvarchar](10) ,
		[STYLEEXT3_ID] [nvarchar](10) ,
		[STYLEEXT4_ID] [nvarchar](10) )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_SUBPRODORDER')
	BEGIN
	CREATE TABLE [dbo].[ODB_SUBPRODORDER](
		[PRODORDER_ID] [int] ,
		[SUBPRODORDER_ID] [int] ,
		[PLANNEDLENGTH] [numeric](28, 12) ,
		[NOMINALPIECELENGTH] [numeric](28, 12) ,
		[SUBPORDCOMMENT] [nvarchar](80) ,
		[NOMINALSPEED] [numeric](28, 12) ,
		[STYLE_ID1] [nvarchar](10) ,
		[WIDTH_ID2] [numeric](28, 12) ,
		[NOOFPIECEPRODLINE1] [int] ,
		[STYLE_ID2] [nvarchar](10) ,
		[WIDTH_ID1] [numeric](28, 12) ,
		[NOOFPIECEPRODLINE3] [int] ,
		[WIDTH_ID4] [numeric](28, 12) ,
		[STYLE_ID3] [nvarchar](10) ,
		[NOOFPIECEPRODLINE2] [int] ,
		[WIDTH_ID3] [numeric](28, 12) ,
		[STYLE_ID4] [nvarchar](10) ,
		[NOOFPIECEPRODLINE4] [int] ,
		[CUSTORDER_ID4] [int] ,
		[SUBCUSTORDER_ID4] [int] ,
		[CUSTORDER_ID1] [int] ,
		[CUSTORDER_ID2] [int] ,
		[SUBCUSTORDER_ID1] [int] ,
		[SUBCUSTORDER_ID2] [int] ,
		[CUSTORDER_ID3] [int] ,
		[SUBCUSTORDER_ID3] [int] ,
		[CREATEPIECES] [int] )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_WARP')
	BEGIN
	CREATE TABLE [dbo].[ODB_WARP](
		[WARP_ID] [int] ,
		[NOMINALLENGTH] [numeric](28, 12) ,
		[WARPTYPE_ID] [nvarchar](20) ,
		[DIRFLAG] [int] ,
		[PRODTYPE] [int] ,
		[UPDPRODPROG] [int] )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_WARPSEQ')
	BEGIN
		CREATE TABLE [dbo].[ODB_WARPSEQ](
			[PRODORDER_ID] [int] ,
			[FEEDLINE_ID] [int] ,
			[WARPSEQ_ID1] [int] ,
			[WARPTYPE_ID3] [nvarchar](20) ,
			[WARP_ID3] [int] ,
			[NOMINALLENGTH3] [numeric](28, 12) ,
			[CONTRACTION3] [numeric](28, 12) ,
			[WARPSEQ_ID2] [int] ,
			[WARP_ID1] [int] ,
			[WARP_ID2] [int] ,
			[NOMINALLENGTH1] [numeric](28, 12) ,
			[NOMINALLENGTH2] [numeric](28, 12) ,
			[CONTRACTION1] [numeric](28, 12) ,
			[CONTRACTION2] [numeric](28, 12) ,
			[WARPTYPE_ID1] [nvarchar](20) ,
			[WARPTYPE_ID2] [nvarchar](20) ,
			[WARPSEQ_ID3] [int] )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_WARPTYPE')
	BEGIN
		CREATE TABLE [dbo].[ODB_WARPTYPE](
			[WARPTYPE_ID] [nvarchar](20) ,
			[WARPTYPECOMMENT] [nvarchar](80) ,
			[NUMBEROFENDS] [int] ,
			[NUMBEROFRIBBON] [int] ,
			[NUMBEROFSECTIONBEAM] [int] ,
			[NUMBEROFWARP] [int] ,
			[NOMINALLENGTH] [numeric](28, 12) ,
			[PASS_ID] [nvarchar](10) ,
			[ACTIVE] [int] ,
			[COLOR] [int] ,
			[BEAMTYPE_ID] [nvarchar](10) ,
			[COSTINV] [numeric](28, 12) ,
			[COSTCAL] [numeric](28, 12) )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_WARPTYPELIST')
	BEGIN
		CREATE TABLE [dbo].[ODB_WARPTYPELIST](
			[WARPTYPE_ID] [nvarchar](20) ,
			[POS_ID] [int] ,
			[NUMBEROF] [int] ,
			[SECWARPTYPE_ID] [nvarchar](16) )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_WARPYARNLIST')
	BEGIN
		CREATE TABLE [dbo].[ODB_WARPYARNLIST](
			[WARPTYPE_ID] [nvarchar](20) ,
			[POS_ID] [int] ,
			[NOMINALEQUALACT] [int] ,
			[NUMBEROFBAND] [int] ,
			[NUMBEROFYARN] [int] ,
			[LOSS] [numeric](28, 12) ,
			[YARNSEQ] [nvarchar](1) ,
			[YARN_ID] [nvarchar](10) )
	END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_WEFTYARNLIST')
BEGIN
CREATE TABLE [dbo].[ODB_WEFTYARNLIST](
	[STYLE_ID] [nvarchar](10) ,
	[WIDTH_ID] [numeric](28, 12) ,
	[MACHTYPE_ID] [nvarchar](4) ,
	[POS_ID] [int] ,
	[PRIORITY_ID] [int] ,
	[DENSITY] [numeric](28, 12) ,
	[LOSS] [numeric](28, 12) ,
	[YARN_ID] [nvarchar](10) )
END

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE name='ODB_YARN')
BEGIN
CREATE TABLE [dbo].[ODB_YARN](
	[ACTIVE] [int] ,
	[YARN_ID] [nvarchar](10) ,
	[YARNDESC] [nvarchar](20) ,
	[COLOR] [int] ,
	[EFFTEX] [numeric](28, 12) ,
	[YARNCOMMENT] [nvarchar](80) ,
	[SUPPLIER_ID] [nvarchar](10) ,
	[FINENESS] [nvarchar](20) ,
	[PLYTWIST] [nvarchar](1) ,
	[PLYSPEED] [numeric](28, 12) ,
	[COSTINV] [numeric](28, 12) ,
	[COSTCAL] [numeric](28, 12) )
END
